import inquirer from "inquirer";

async function promptQuestions() {
    let answers;
    try {
        answers = await inquirer.prompt([
            // ... questions
            {
                type: "input",
                name: "username",
                message: "请输入您的用户名:"
            },
            {
                type: "confirm",
                name: "isVIP",
                message: "您是VIP用户吗?",
                default: false
            },
            {
                type: "list",
                name: "plan",
                message: "请选择您的计划:",
                choices: ["Free", "Professional", "Enterprise"],
                filter: function (val) {
                    return val.toLowerCase();
                }
            }
        ]);

        console.log(JSON.stringify(answers, null, "  "));
    } catch (error) {
        if (error.isTtyError) {
            console.log("Prompt couldn't be rendered in the current environment");
        } else {
            console.log("Something else went wrong");
        }
    }

    return answers;
}

export default promptQuestions;
